#!/usr/bin/env python
#pip install matplotlib -i https://mirrors.aliyun.com/pypi/simple/
#https://matplotlib.org/
#绘制多次图型和不同同型差异
from matplotlib import pyplot as plt
import random 
import matplotlib 
font = {'family' : 'MicroSoft YaHei','size':'12'}
matplotlib.rc("font",**font)

x = range(11,31)

y_1 = [1,0,1,1,2,4,3,2,3,4,4,5,6,5,4,3,3,1,1,1]
y_2 = [1,0,3,1,2,2,1,2,3,1,2,1,3,2,4,1,1,1,1,1]

#设置图型大小
plt.figure(figsize=(20,8),dpi=80)

plt.plot(x,y_1,label="自己",color="r",linestyle=":")
plt.plot(x,y_2,label="同桌",color='#4169e1',linestyle="--",linewidth=5,alpha=0.5)

_xtick_labels = ["{}岁".format(i) for i in x]
plt.xticks(x,_xtick_labels)

plt.grid(alpha=0.4)

#添加图例--自己、同桌
plt.legend(loc='upper left') #默认右上角




plt.show()